package Threadtest;

public class demo3 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{

            for (int i = 0; i < 6; i++) {
                try {
                    Thread.sleep(1000);
                    System.out.println("t1");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        Thread t2 = new Thread(()->{

            try {
                Thread.sleep(500);
                t1.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            for (int i = 0; i < 3; i++) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t2");
            }
        });
        t1.start();
        t2.start();

        t2.join();

    }
}
